package co.gov.medellin.ssti.sub.model.dao;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.TreeMap;

import co.gov.medellin.ssti.sub.common.excepcion.SUBException;

/**
 * Clase DAO Padre, sobre la cual los demas DAOS extenderan sus funciones.
 * 
 * @author acespedes Consult-Soft S.A.
 * @version 4.0 28/11/2011
 * @since 1.4
 */
public interface BaseDAO {

	// ------------------------------------------------------------------------
	// Metodos Publicos
	// ------------------------------------------------------------------------

	/**
	 * Metodo sobrecargado que cierra un preparedStatement e ignora la
	 * excepcion.
	 * 
	 * @param con
	 */
	void close(Connection con);

	/**
	 * Metodo sobrecargado que cierra un preparedStatement e ignora la
	 * excepcion.
	 * 
	 * @param rs
	 */
	void close(ResultSet rs);
	/**
	 * Metodo sobrecargado que cierra un preparedStatement e ignora la
	 * excepcion.
	 * 
	 * @param stmt
	 */
	void close(Statement stmt);

	/**
	 * Cierra silenciosamente la Connection, Statement y ResultSet. Cualquier
	 * error es impreso en el stderr.
	 * 
	 * @param connection
	 *            The Connection to be closed quietly.
	 * @param statement
	 *            The Statement to be closed quietly.
	 * @param resultSet
	 *            The ResultSet to be closed quietly.
	 */
	void close(Connection connection, Statement statement,
			ResultSet resultSet);

	/**
	 * Creates a Prepared Statement Query using variable arguments for a custom
	 * search, if the query has no arguments or values the query remains the
	 * same and no search params are added, this allows to make a custom search
	 * without having to add a lot of if-else statements
	 * 
	 * @param baseQuery
	 *            a database query that contains no search parameters
	 * @param queryParams
	 *            search parameters which are pairs that contain criteria and
	 *            values&#8203;&#8203;, which are added to the database query to
	 *            generate a ready to run PreparedStatement
	 * @param connection
	 *            connection to the database open and ready for querys
	 * @return returns a PreparedStatement with variable search parameters to
	 *         get data ready to run
	 */
	// PreparedStatement setQueryParams(String baseQuery, TreeMap<String,
	// Object> queryParams,
	PreparedStatement setQueryParams(String baseQuery,
			TreeMap queryParams, Connection connection) throws SQLException;

}